package control;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.Record;
import service.RecordService;
import service.RecordServiceimpl;

public class Addrecord  extends HttpServlet{
	//在做数据查询时，建议用Get方式；而在做数据添加、修改或删除时，建议用Post方式；


	RecordService rs = new RecordServiceimpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doGet(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO Auto-generated method stub
		
		String email = null;
		Integer typeid = null;;
		String password = null;
		for(Cookie c:req.getCookies()) {
			if(c.getName().equals("email")) {
				email = c.getValue();
			}
			if(c.getName().equals("typeid")) {
				typeid = Integer.valueOf(c.getValue());
			}
			if(c.getName().equals("password")) {
				password = c.getValue();
			}
		}
		
		    System.out.println("addrecord");
		    req.setCharacterEncoding("utf-8");
	       
	        Integer wordID=Integer.valueOf(req.getParameter("wordid"));
	        Integer count=1;
	        Integer flag=Integer.valueOf(req.getParameter("type"));

			try {
				rs.update(email, wordID, flag);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

	}
}
